<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
<link href="<%=request.getContextPath()%>/css/login.css" rel="stylesheet" type="text/css">
<c:if test="${errCode == null}">
	<c:set var="errCode" value="\"\""></c:set>
</c:if>
<script type="text/javascript">
	function checkErrCode(){
		var errCode = ${errCode};
		if(errCode != null || errCode != ""){
			switch (errCode) {
			case 1:
				alert("가입된 아이디(이)가 아닙니다!");
				break;
			case 2:
				alert("비밀번호가 일치하지 않습니다!");
				break;
			case 3:
				alert("회원가입 처리가 완료되었습니다! 로그인 해 주세요!");
				location.href = "<%=request.getContextPath()%>/login.do";
				break;		
			}
		}
	}
	
// 	 추가 function
	function logchk(){
		var regx =/^[a-zA-Z0-9]*$/;
		var userID= document.form.userID.value;
		var pass=document.form.pass.value;
		
		if(userID.length==0 || userID==null){
			alert("아이디를 입력하세요");
			document.form.userID.focus();
			return;
		}
		if(!regx.test(userID)){
			alert("아이디는 영어,숫자만 입력가능합니다");
			document.form.userID.focus();
			return false;
		}
		if(pass.length<6 || pass==null){
			alert("비밀번호는 6글자 이상입니다.");
			document.form.pass.focus();
			return;
			
		}
		document.form.submit();
	}
function findid(){
		location.href = "findid.do";
}
</script>
</head>
<body onload="checkErrCode()">
<!-- TOP -->

<jsp:include page='top1.jsp'/>
<!-- TOP종료 -->

<div class="wrapper" align="center">

	<spring:hasBindErrors name="LoginModel" />
	<form:errors path="LoginModel" />
	<form action="login.do" method="post">
	
		<fieldset class="fld_comm">
		<legend class="screen_out">아이디 입력</legend>
		<div class="bg_user input_info">
		<label for="id" class="lab_g"></label>
		<input type="text" id="userId" name="userId" class="tf_g" value="" placeholder="아이디 입력"  />
		</div>
	
	    <span class="error"><form:errors path="LoginModel.userId" /></span><br />
		<div class="bg_user input_info">
		<label for="inputPwd" class="lab_g"></label>	
		<input type="password" id="userPw" name="userPw" class="tf_g" autocomplete="off" placeholder="비밀번호 입력"/>
		</div>
		<span class="error"><form:errors path="LoginModel.userPw" /></span>
			
			<input type="submit" value="로그인" class="btn_login"/><br /><br />
			<a href="<%=request.getContextPath()%>/member/join1.do">회원가입/</a>		
			<a href="<%=request.getContextPath()%>/findid.do">아이디 찾기/</a>
			<a href="<%=request.getContextPath()%>/findpass.do">비밀번호 찾기</a>
					
		</fieldset>			
	</form>

</div>
<!-- BOTTOM -->

<jsp:include page="bottom.jsp"/>
<!-- BOTTOM 종료 -->
</body>
</html>